<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/include/TLDInclude.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>user.jsp</title>
		<%@ include file="/WEB-INF/common/include/meta.jsp"%>
		<%@ include file="/WEB-INF/common/include/jquery.jsp"%>
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>

	<body>
		<c:if test="${not empty msg}">
			<div id="message" style="color: red;" align="center">
				${msg}
			</div>
		</c:if>
		<div align="center">
			<form:form method="post">
				<spring:message code="username" />:<input type="text" name="username">
				<input type="submit" value="<spring:message code="search" />" />
			</form:form>
			<input type="button" value="<spring:message code="add" />" onclick="window.location = '${ctx}/demo/input'">
			<table>
				<tbody>
					<tr>
						<th>
							id
						</th>
						<th>
							<spring:message code="username" />
						</th>
						<th>
							<spring:message code="gender" />
						</th>
						<th>
							<spring:message code="birthday" />
						</th>
						<th>
							<spring:message code="operation" />
						</th>
					</tr>
					<c:forEach items="${userList}" var="user">
						<tr>
							<td>
								${user.id}
							</td>
							<td>
								${user.username}
							</td>
							<td>
								<c:choose>
									<c:when test="${user.gender == 0}">
										<spring:message code="male" />
									</c:when>
									<c:otherwise>
										<spring:message code="female" />
									</c:otherwise>
								</c:choose>
							</td>
							<td>
								<fmt:formatDate value="${user.birthday}" pattern="yyyy-MM-dd" />
							</td>
							<td>
								<a href="${ctx}/demo/input?id=${user.id}"><spring:message code="edit" /></a>
								/
								<a href="#"
									onclick="javascript: if (confirm('<spring:message code="confirm.delete" />')) window.location = '${ctx}/demo/delete/${user.id}';"><spring:message code="delete" /></a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</body>
</html>
